package com.baidu.bm.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

import com.baidu.bm.model.BookEntity;

/**
 * This class defines the data access object for book entity.
 * Any action to the database must be associated to this class.
 * @author Sean
 *
 */
@Repository
public class BookEntityDao {
	
	@Autowired
	private SqlMapClientTemplate sqlMapClientTemplate;

	public SqlMapClientTemplate getSqlMapClientTemplate() {
		return sqlMapClientTemplate;
	}

	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) {
		this.sqlMapClientTemplate = sqlMapClientTemplate;
	}
	
	/**
	 * Get the book entity by its ID
	 * @param bookEntityId The given ID
	 * @return The book entity if exist.
	 * 			Otherwise a null will returned.
	 */
	public BookEntity getBookEntityById(Integer bookEntityId) {
		return (BookEntity)sqlMapClientTemplate.queryForObject("getBookEntityById",bookEntityId);
	}
}
